package main

import (
	"fmt"
	"sync"
	"time"
)

func isPrime(num int) {
	defer wg.Done()
	var flag = true
	for j := 2; j < num; j++ {
		if num%j == 0 {
			flag = false
			break
		}
	}
	if flag {
		// fmt.Printf("%v 是素数\n", num)
	}
}

var wg sync.WaitGroup

func main() {
	var startTime = time.Now()
	for i := 0; i < 1000000; i++ {
		wg.Add(1)
		go isPrime(i)
	}
	wg.Wait()
	var runTime = time.Since(startTime)
	fmt.Printf("程序运行时间：%v\n", runTime)
}
